<?php
/**
 * Created by JetBrains PhpStorm.
 * User: admin
 * Date: 19.01.13
 * Time: 13:18
 * To change this template use File | Settings | File Templates.
 */

class Application_Api_Core extends Application_Api_Abstract
{

  public function getViewer()
  {
    if (Zend_Auth::getInstance()->hasIdentity()) {
      return Zend_Auth::getInstance()->getIdentity();
    }
    return false;
  }

  public function isAllowed($resource, $role, $action = 'view')
  {

  }

  public function isAdmin()
  {
    $viewer = $this->getViewer();
    $role = $viewer ? $viewer->role : 'public';
    return in_array((string)$role, array('admin', 'moderator'));
  }

}